package com.example.demo_1106.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo_1106.entity.RiderInfo;
import com.example.demo_1106.service.RiderInfoService;
import com.example.demo_1106.mapper.RiderInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kongke
 * @description 针对表【rider_info】的数据库操作Service实现
 * @createDate 2023-07-23 10:09:06
 */
@Service
public class RiderInfoServiceImpl extends ServiceImpl<RiderInfoMapper, RiderInfo>
        implements RiderInfoService {

    @Autowired
    RiderInfoMapper riderInfoMapper;

    /**
     * 删除搬手信息
     *
     * @param ridercode 搬手编号
     * @return boolean
     */
    @Override
    public boolean delRiderinf(String ridercode) {
        int del = riderInfoMapper.delete(new QueryWrapper<RiderInfo>().eq("rider_code", ridercode));
        return del != 0;
    }

    /**
     * 查询搬手信息
     *
     * @param ridercode 搬手编号
     * @return {@link List}<{@link RiderInfo}>
     */
    @Override
    public List<RiderInfo> getRider(String ridercode) {
        List<RiderInfo> riderInfoList;
        if ("".equals(ridercode) || ridercode == null) {
            riderInfoList = riderInfoMapper.selectList(null);
        } else {
            riderInfoList = riderInfoMapper.selectList(new QueryWrapper<RiderInfo>().eq("rider_code", ridercode));
        }
        return riderInfoList;
    }
}




